#pragma once

#include "Node.h"
#include "Operand.h"
#include "Lexer"
#include <map>
#include "PrologException.h"
#include "Variables.h"

class Interpreter
{
public:
	Interpreter(std::string filename);
	~Interpreter(void);
	Node* getRootNode() const;
	Node* parse(Node**, std::string&) throw (PrologException);
	std::string prove();
private:
	static int		priority;
	Node*			tree;
	quex::Token*	token;
    quex::Lexer*	qlex;
	vector<Node*>	predicates;
	vector<Node*>	domains;
	unsigned int	sizeClauses;
	std::vector<Variables>	vars;
	void			addStandartPredicate(Node**, std::string);
	Node*			containsDomain(std::string) const;
	Node*			containsPredicate(std::string) const;
	void			swapNode(Node**, Node**, std::string, std::string, int);
	bool			goal;
	bool			goalPredicate;
};

std::string printTree(Node* tree, int count);